Skip to content

London | 26-SDC-Mar | Beko | Sprint 1 | Individual shell tools exercises#352

Open
Abubakar-Meigag wants to merge 2 commits into
CodeYourFuture:mainfrom
Abubakar-Meigag:beko-individual-shell-tools
Open

London | 26-SDC-Mar | Beko | Sprint 1 | Individual shell tools exercises#352
Abubakar-Meigag wants to merge 2 commits into
CodeYourFuture:mainfrom
Abubakar-Meigag:beko-individual-shell-tools

Conversation

@Abubakar-Meigag

Copy link
Copy Markdown
Contributor

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

complete individual shell tools exercises

Questions

no questions, thanks!

@github-actions

This comment has been minimized.

@Abubakar-Meigag Abubakar-Meigag added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 11, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 11, 2026
@Abubakar-Meigag Abubakar-Meigag added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 11, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 11, 2026
@Abubakar-Meigag Abubakar-Meigag changed the title London | 26-SDC-Mar | Beko | Sprint1 | Individual shell tools exercises London | 26-SDC-Mar | Beko | Sprint 1 | Individual shell tools exercises Mar 11, 2026
@Abubakar-Meigag Abubakar-Meigag added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 1 Assigned during Sprint 1 of this module Module-Tools The name of the module. labels Mar 11, 2026

@SlideGauge SlideGauge left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There a couple of files which do not have empty line in the end of the file (like wc/script-02.sh). Could you add them please

Comment thread individual-shell-tools/awk/script-01.sh Outdated

set -euo pipefail

awk '{print NF}' scores-table.txt

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does NF mean in this context and what will this line output?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NF counts the number of fields in each row, so it was outputting the word count per line rather than the names

I've updated the command to use $1 instead, which prints the value of the first field.

Comment thread individual-shell-tools/awk/script-04.sh Outdated

set -euo pipefail

awk '/London/ {print $1, $4}' scores-table.txt

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when we meet lines with different number of scores?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$4 is hardcoded so it won't work for players with different number of scores
i should use $NF instead which always points to the last field.

set -euo pipefail


grep -v "Hello" dialogue.txt

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it find lines like "hello" (lowercase)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it won't catch lowercase 'hello' because grep is case-sensitive by default.

i've added the -i flag to make it case-insensitive

Comment thread individual-shell-tools/ls/script-01.sh Outdated
# TODO: Write a command to list the files and folders in this directory.
# The output should be a list of names including child-directory, script-01.sh, script-02.sh, and more.

ls ../ls

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README file says
"You should write all of your scripts assuming they're running inside the directory they're saved in."
Whilst this line works, it does redundant operation with the path, could you simplify it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the script runs in its own directory

i can just use ls with no path.

updated

Comment thread individual-shell-tools/ls/script-02.sh Outdated
# TODO: Write a command which lists all of the files in the directory named child-directory.
# The output should be a list of names: helper-1.txt, helper-2.txt, helper-3.txt.

ls ../ls/child-directory No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README file says
"You should write all of your scripts assuming they're running inside the directory they're saved in."
Whilst this line works, it does redundant operation with the path, could you simplify it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment thread individual-shell-tools/ls/script-04.sh Outdated

echo "First exercise (sorted newest to oldest):"

ls -t ../ls/child-directory

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README file says
"You should write all of your scripts assuming they're running inside the directory they're saved in."
Whilst this line works, it does redundant operation with the path, could you simplify it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Comment thread individual-shell-tools/ls/script-03.sh Outdated
# The output should be a list of names including: child-directory, script-01.sh, helper-1.txt (and more).
# The formatting of the output doesn't matter.

ls ../ls ../ls/child-directory No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, will it output directories contents recursively?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


set -euo pipefail

grep -l "Doctor:" *.txt

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it output only lines of the Doctor or can it potentially output lines which contain "Doctor:" somewhere in the middle?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can match 'Doctor:' anywhere in the line

so I've added ^ to anchor it to the start.

Comment thread individual-shell-tools/awk/script-04.sh Outdated

set -euo pipefail

awk '/London/ {print $1, $4}' scores-table.txt

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen if some of the player's have name "London" but the city is not London?


set -euo pipefail

awk '{for (i=3; i<=NF; i++) sum[$1] += $i} END {for (name in sum) print name, sum[name]}' scores-table.txt

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does for (name in sum) guarantee the order of traversal?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually no, for (name in sum) doesn't guarantee order
because awk arrays are associative so traversal is arbitrary

i've fixed it by tracking the names in a separate ordered array

@SlideGauge SlideGauge added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 31, 2026
@SlideGauge

Copy link
Copy Markdown

Wrote my notes, could you fulfil them please?

@Abubakar-Meigag Abubakar-Meigag added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Jun 7, 2026
@Abubakar-Meigag

Copy link
Copy Markdown
Contributor Author

Hi @SlideGauge thanks for the review, I've completed all the changes for the code review and feedback

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Tools The name of the module. Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants